import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)

export default new Vuex.Store({
  // 持久化存储
  plugins: [
    createPersistedState(),
  ],
  state: {
    showModal: false,
    isLogin: false,
    userInfo: {},
    shoppingCartList: [],
    count: 0,//购物车数量
  },
  getters: {
  },
  mutations: {
    setShowModel(state, showModal) {
      state.showModal = showModal
    },
    setIsLogin(state, isLogin) {
      state.isLogin = isLogin
    },
    setUserInfo(state, userInfo) {
      state.userInfo = userInfo
    },
    setShoppingCartList(state, shoppingCartList) {
      state.shoppingCartList = shoppingCartList
    },
    setCount(state, count) {
      state.count = count
    }
  },
  actions: {
  },
  modules: {
  }
})
